#include "mytcpserver.h"
#include "clienthandle.h"
#include <QThread>

MyTcpServer::MyTcpServer(QObject *parent) : QTcpServer{parent}
{}

//有客户端连接会触发中国函数
void MyTcpServer::incomingConnection(qintptr socketDescriptor)
{    //启动线程
    QThread *subThread = new QThread;   //线程对象
    ClientHandle *myClient = new ClientHandle(socketDescriptor);  //事件对象

    myClient->moveToThread(subThread);

    subThread->start();  //启动线程

    connect(this,&::MyTcpServer::signal_to_thraed,myClient,&ClientHandle::working);
    emit signal_to_thraed();
}
